package ifosup.julien.socket;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.Map;

public class EssaiUrl {
	public void facebook() {
		try {
			URL url1 = new URL("http", "www.facebook.com", "");
			HttpURLConnection connection = (HttpURLConnection) url1
					.openConnection();
			connection.connect();
			Map<String, List<String>> mapHeader = connection.getHeaderFields();
			for (String key : mapHeader.keySet()) {
				System.out.println(key + "   " + mapHeader.get(key));
			}
			InputStream inputStream = connection.getInputStream();
			StringBuffer buffer = new StringBuffer();
			int c = 0;
			while ((c = inputStream.read()) >= 0) {
				buffer.append((char) c);
			}
			System.out.println(buffer);
			connection.disconnect();
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
